package com.evan.webadmin.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.evan.webadmin.biz.model.ExamItem;
import com.evan.webadmin.biz.dao.ExamItemMapper;
import com.evan.webadmin.biz.model.SubjectOption;
import com.evan.webadmin.biz.service.IExamItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Pavel
 * @since 2024-06-10
 */
@Service
public class ExamItemServiceImpl extends ServiceImpl<ExamItemMapper, ExamItem> implements IExamItemService {

    @Autowired
    ExamItemMapper examItemMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void deleteByExamId(Long examId) {
        examItemMapper.deleteByExamId(examId);
    }

    @Override
    public List<ExamItem> findByExamId(Long examId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("exam_id", examId);
        return examItemMapper.selectList(queryWrapper);
    }
}
